package com.demo.behavioral.observer;

import java.util.ArrayList;
import java.util.List;

public class CtripTicketBuy implements ITicketObservable{
	
	private List<ITicketObserver> observers = new ArrayList<ITicketObserver>();

	public void addObserver(ITicketObserver observer) {
		observers.add(observer);
	}

	public void notifyAllObservers() {
		for(ITicketObserver observer :observers){
			observer.actAfterBuyTicket();
		}
	}
	
	public void buyTicket(){
		notifyAllObservers();
	}

}
